let s = 'aadadaad'
var firstUniqChar = function (s) {
    let arr = [...s]
    let arr1 = []
    let queue = []
    for (let i = 0; i < arr.length; i++) {
        if (queue.length && queue.find(element => element === arr[i]) !== undefined || arr1.find(element => element === arr[i]) !== undefined) {
            queue = queue.filter(item => item !== arr[i])
            arr1.push(arr[i])
        } else {
            queue.push(arr[i])
        }
    }


    for (let j = 0; j < arr.length; j++) {
        if (arr[j] === queue[0]) {
            return j
        }
    }
    return -1
};
console.log(firstUniqChar(s));
